#include <iostream>
#include <vector>

using namespace std;

class Solution {
public:
    int maxProduct(vector<string>& words) {
        vector<uint32_t> word_bits(words.size(), 0);
        for (int i = 0; i < words.size(); i++) {
            for (char item : words[i]) {
                word_bits[i] |= 1 << item - 'a';
            }
        }
        int ans = INT32_MIN;
        for (int i = 0; i < word_bits.size(); i++) {
            for (int j = i + 1; j < word_bits.size(); j++) {
                if ((word_bits[i] & word_bits[j]) == 0) {
                    ans = max(ans, (int) words[i].size() * (int) words[j].size());
                }
            }
        }
        return ans == INT32_MIN ? 0 : ans;
    }
};

int main() {
    vector<string> input = {"abcw", "baz", "foo", "bar", "xtfn", "abcdef"};
    Solution solution;
    int output = solution.maxProduct(input);
    cout << output << endl;
}